/*
package com.example.demo.commons.core.codec;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.map.MapUtil;

import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;

import java.util.List;
import java.util.Map;

*/
/**
 * <p> 签名 </p>
 *
 * @author tanyunpeng
 * @date 2021/11/18
 *//*

@Slf4j
public class SignatureUtil {

    */
/**
     * 等于符号标志
     *//*

    private static final String EQ_SYMBOL = "=";

    */
/**
     * 并且符号标志
     *//*

    private static final String AND_SYMBOL = "&";

    */
/**
     * 获取签名原串
     * <p>1.排除某些字符串Key值</p>
     * <p>2.根据key对传来的map数据排序</p>
     * <p>3.生成a1=b1&a2=b2&a3=b3形式的字符串</p>
     *
     * @param params         要排序的参数
     * @param excludeKeyList 要排序的key值
     * @return 签名原串
     *//*

    public static String getSignData(Map<String, Object> params, List<String> excludeKeyList) {
        Map<String, Object> map = Maps.newHashMap(params);
        if (CollectionUtil.isNotEmpty(excludeKeyList)) {
            for (String key : excludeKeyList) {
                map.remove(key);
            }
        }
        return MapUtil.join(MapUtil.sort(map), AND_SYMBOL, EQ_SYMBOL, true);
    }

    */
/**
     * MD5签名
     *
     * @param params         要排序的参数
     * @param excludeKeyList 要排序的key值
     * @return 摘要
     *//*

    public static String signMD5(Map<String, Object> params, List<String> excludeKeyList) {
        final String signData = getSignData(params, excludeKeyList);
        log.info("MD5签名字符原串:{}", signData);
        return new Digester(DigestAlgorithm.MD5).digestHex(signData);
    }

    */
/**
     * RSA加签
     *
     * @param params           签名参数
     * @param excludeKeyList   需要排除的属性
     * @param privateKeyBase64 私钥
     * @return 签名
     *//*

    public static String signRSA(Map<String, Object> params, List<String> excludeKeyList, String privateKeyBase64) {
        final String signData = getSignData(params, excludeKeyList);
        log.info("RSA签名字符原串:{}", signData);
        Sign sign = SecureUtil.sign(SignAlgorithm.MD5withRSA, privateKeyBase64, null);
        byte[] signed = sign.sign(signData);
        String signHex = new String(Base64.encodeBase64(signed));
        log.info("RSA签名后字符串:{}", signHex);
        return signHex;
    }

    */
/**
     * RSA验签
     *
     * @param params          签名参数
     * @param excludeKeyList  需要排除的属性
     * @param publicKeyBase64 私钥
     * @return 验签结果
     *//*

    public static boolean checkSignRSA(String signStr, Map<String, Object> params, List<String> excludeKeyList,
                                       String publicKeyBase64) {
        final String signData = getSignData(params, excludeKeyList);
        Sign sign = SecureUtil.sign(SignAlgorithm.MD5withRSA, null, publicKeyBase64);
        byte[] signed = Base64.decodeBase64(signStr);
        return sign.verify(signData.getBytes(), signed);
    }
}
*/
